#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=310;
typedef long long LL;
typedef pair<int,int> PI;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
int ma[maxn][maxn];
bool vis[maxn][maxn];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
struct P{
    int l1,r1;
    int l2,r2;
};
vector<int> bfs(int x,int y,int m,int n)
{
    queue<PI>que;
    que.push({x,y});
    vis[x][y]=1;
    int l1=INT_MAX; int r1=INT_MAX;
    int l2=-1; int r2=-1;
    while(!que.empty())
    {
        PI now=que.front();que.pop();
        if(l1>=now.first){
           l1=min(l1,now.first);
           r1=min(r1,now.second);
        }
        if(l2<=now.first)
        {
           l2=max(l2,now.first);
           r2=max(r2,now.second);
        }
        for(int i=0;i<4;i++)
        {
            int nx=now.first+dx[i];
            int ny=now.second+dy[i];
            if(vis[nx][ny]||nx<1||nx>m||ny<1||ny>n) continue;
            if(ma[nx][ny]==0) continue;
            vis[nx][ny]=1;
            que.push({nx,ny});
        }
    }
    vector<int>v;
    v.push_back(l1);v.push_back(r1);v.push_back(l2);v.push_back(r2);
    return v;
}
vector<vector<int>> findFarmland(vector<vector<int>>& land) {
    vector<vector<int>>ans;
    if(land.empty()) return ans;

    for(int i=0;i<land.size();i++)
    {
        for(int j=0;j<land[i].size();j++)
        {
            ma[i+1][j+1]=land[i][j];
        }
    }
    int m=land.size();int n=land[0].size();
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(!vis[i][j]&&ma[i][j]==1)
            {
                vector<int> res=bfs(i,j,m,n);
                ans.push_back(res);
            }
        }
    }
    return ans;
}
int main(void){


   	return 0;
}
